$(function () {
    init_ex_detail();
});

/**初始化资料**/
function init_ex_detail() {
    var ex_id = $("#customer_ids").val();
    if(ex_id == "" || ex_id == undefined){$JuXue.n_danger("获取客户资料失败");return }

    $.post(ctx+"seaExtension/getExEmpDetail",{ids:ex_id},function (r) {
        if (r.code == 0){
            var data = r.msg;
            $("#exName").text(data.cExName);$("#ex_name").text(data.cExName);
            $("#ex_mobile").text(data.cExPhone);$("#ex_pnoe").text(data.cExMobile);$("#exphone").text(data.cExMobile);
            $("#ex_wechat").text(data.cExWechat);$("#ex_qq").text(data.cExQq);$("#ex_email").text(data.cExEmail);$("#exEmail").text(data.cExEmail);
            $("#ex_project").text(data.cExIntern);$("#ex_groud").text(data.cExGroud);$("#ex_init").text(data.cExInit);
            $("#ex_source").text(data.cExSource);$("#ex_key").text(data.cExKey);$("#ex_time").text(data.cExTime);
            $("#ex_zone").text(data.cExzone);$("#ex_chanel").text(data.cExChanel);$("#ex_zi_source").text(data.cExZiSource);
            /**初始话修改得内容**/
            init_edit_exemp(data.cExId);
        }else{
            $JuXue.n_danger(r.msg)
        }
    });
}

/**初始化客户资料得修改**/
function init_edit_exemp(extId) {
    /**修改客户名称**/
    $("#ex_name").editable({
        url:function (parame) {
            $.post(ctx+"seaExtension/updateExEmpDetail",{cExName:parame.value,cExId:extId},function (r) {
                if (r.code === 0) {
                    $JuXue.n_success(r.msg);
                    $("#exName").text(parame.value);
                    $JuXue.refreshTable("bigExEmpTable");
                } else {
                    $JuXue.n_danger(r.msg);
                }
            });
        },
        pk:extId,
        defaultValue:"",
        title:"修改客户名称",
        validate: function (value) { //字段验证
            if (!$.trim(value)) {
                return '不能为空';
            }
        }
    });
    /**修改客户电话**/
    $("#ex_mobile").editable({
        url:function (parame) {
            $.post(ctx+"seaExtension/updateExEmpDetail",{cExPhone:parame.value,cExId:extId},function (r) {
                if (r.code === 0) {
                    $JuXue.n_success(r.msg);
                    //$JuXue.refreshTable("bigExEmpTable");
                } else {
                    $JuXue.n_danger(r.msg);
                }
            });
        },
        pk:extId,
        defaultValue:"",
        title:"修改客户电话",
        validate: function (value) { //字段验证
            if (!$.trim(value)) {
                return '不能为空';
            }
        }
    });
    /**修改客户电话**/
    $("#ex_pnoe").editable({
        url:function (parame) {
            $.post(ctx+"seaExtension/updateExEmpDetail",{cExMobile:parame.value,cExId:extId},function (r) {
                if (r.code === 0) {
                    $JuXue.n_success(r.msg);
                    $("#exphone").text(parame.value);
                    $JuXue.refreshTable("bigExEmpTable");
                } else {
                    $JuXue.n_danger(r.msg);
                }
            });
        },
        pk:extId,
        defaultValue:"",
        title:"修改客户手机",
        validate: function (value) { //字段验证
            if (!$.trim(value)) {
                return '不能为空';
            }
        }
    });
    /**修改客户得微信**/
    $("#ex_wechat").editable({
        url:function (parame) {
            $.post(ctx+"seaExtension/updateExEmpDetail",{cExWechat:parame.value,cExId:extId},function (r) {
                if (r.code === 0) {
                    $JuXue.n_success(r.msg);
                    $JuXue.refreshTable("bigExEmpTable");
                } else {
                    $JuXue.n_danger(r.msg);
                }
            });
        },
        pk:extId,
        defaultValue:"",
        title:"修改客户微信",
        validate: function (value) { //字段验证
            if (!$.trim(value)) {
                return '不能为空';
            }
        }
    });
    /**修改客户得QQ**/
    $("#ex_qq").editable({
        url:function (parame) {
            $.post(ctx+"seaExtension/updateExEmpDetail",{cExQq:parame.value,cExId:extId},function (r) {
                if (r.code === 0) {
                    $JuXue.n_success(r.msg);
                    $JuXue.refreshTable("bigExEmpTable");
                } else {
                    $JuXue.n_danger(r.msg);
                }
            });
        },
        pk:extId,
        defaultValue:"",
        title:"修改客户QQ",
        validate: function (value) { //字段验证
            if (!$.trim(value)) {
                return '不能为空';
            }
        }
    });
    /**修改邮箱**/
    $("#ex_email").editable({
        url:function (parame) {
            $.post(ctx+"seaExtension/updateExEmpDetail",{cExEmail:parame.value,cExId:extId},function (r) {
                if (r.code === 0) {
                    $JuXue.n_success(r.msg);
                    $("#exEmail").text(parame.value);
                    $JuXue.refreshTable("bigExEmpTable");
                } else {
                    $JuXue.n_danger(r.msg);
                }
            });
        },
        pk:extId,
        defaultValue:"",
        title:"修改客户邮箱",
        validate: function (value) { //字段验证
            if (!$.trim(value)) {
                return '不能为空';
            }
        }
    });


}
